{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "64e9c466-9328-49ff-bc80-f2b73d2d6c39",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3×4的数组:\n",
      " [[110 120  90  80]\n",
      " [ 89  95  77  92]\n",
      " [ 60  79  96  80]]\n",
      "第三行和第一行的元素:\n",
      " [[ 60  79  96  80]\n",
      " [110 120  90  80]]\n",
      "第三行第二列和第一行第一列的元素 [ 79 110]\n",
      "大于80且小于等于100的所有元素 [90 89 95 92 96]\n",
      "大于等于80的所有元素: [80 77 60 79 80]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "arr = np.array([[110,120,90,80],[89,95,77,92],[60,79,96,80]])\n",
    "print('3×4的数组:\\n',arr)\n",
    "print('第三行和第一行的元素:\\n',arr[[2,0]])\n",
    "print('第三行第二列和第一行第一列的元素',arr[[2,0],[1,0]])\n",
    "print('大于80且小于等于100的所有元素',arr[(arr>80)&(arr<=100)])\n",
    "print('大于等于80的所有元素:',arr[arr<=80])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8c9cc144-7833-4a1d-98ae-98ae1ab6a938",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character '）' (U+FF09) (2772948648.py, line 6)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn[3], line 6\u001b[1;36m\u001b[0m\n\u001b[1;33m    print('数组的dtype属性:',arr.dtype）\u001b[0m\n\u001b[1;37m                                 ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character '）' (U+FF09)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "arr = np.array([[11,13,18,],[45,46,78,],[15,87,33,]])\n",
    "print('数组的ndim属性:',arr.nidm)\n",
    "print('数组的shape属性:',arr.shape)\n",
    "print('数组的size属性:',arr.size)\n",
    "print('数组的dtype属性:',arr.dtype）\n",
    "print('索引第二行第三列的元素:\\n',arr[[1,2]])\n",
    "print('切片第二行，列步长为2的元素'arr[[1,::2]])\n",
    "print('切片第1~2行，第2~3列的元素'arr[0:2,[1,3])\n",
    "print('通过整数数组作为索引第1行第二列、第二行第三列的元素:'arr[[0,1],[1,2]])\n",
    "print('通过使用布尔型索引大于30小于80的元素',arr[(arr>30)&(arr<80)])\n",
    "arr2=np.linspace(5,50,num=6,retstep=True)\n",
    "print('通过linspace函数创建[5,50]区间,元素个数为6的等差数列,显示公差:',arr2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49e5ad31-ec92-474d-9d79-b9139fc78f7a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
